package com.gxuwz.medical.web.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.gxuwz.medical.database.DbUtil;
import com.gxuwz.medical.domain.user.User;

public class UserServlet extends BaseServlet{
	public void selectUser(HttpServletRequest request,HttpServletResponse response ) 
			throws ServletException, IOException, SQLException{
		List<User> list = new ArrayList<User>();
		//查询t_user表
		String sql="SELECT user_id,pwd,full_name FROM t_user";
		Connection conn = DbUtil.getConn();
		PreparedStatement pst = conn.prepareStatement(sql);
		ResultSet rs = pst.executeQuery();
		//遍历结果集
		while(rs.next()){
			User user= new User();
			user.setUserid(rs.getInt("user_id"));
			user.setPwd(rs.getString("pwd"));
			user.setFullname(rs.getString("full_name"));
			list.add(user);
		}
		request.setAttribute("list", list);	
		request.getRequestDispatcher("/page/user/user_list.jsp").forward(request, response);
	}
	//添加用户
	public void addUser(HttpServletRequest request,HttpServletResponse response){
		String sql="insert into t_user(user_id,pwd,full_name)value";
	}

}
